package com.ada.demo

object TestSingleTon2 extends App {
  val singleTon = SingleTon.getInstance
  val singleTon2 = SingleTon.getInstance
  println(singleTon.hashCode() + " ~ " + singleTon2.hashCode())
  println(singleTon == singleTon2)
}

//将SingleTon的构造方法私有化
class SingleTon private() {
  println("~~~")
}

object SingleTon {
  private val s: SingleTon = new SingleTon

  def getInstance = {
    s
  }
}
